﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileProcessor
{
	public static class SubSetFactory
	{
		public static SubSet Link(SubSet sa,SubSet sb)
		{
			SubSet result = new SubSet();
			for (int a=0;a<sa.Count;a++)
			{
				for (int b=0;b<sb.Count;b++)
				{
					result.AddData(sa.Get(a) + sb.Get(b));
				}
			}
			return result;
		}
		public static SubSet CreatSubSetByOrder(string start,string end,string behavior,string increment)
		{
			SubSet ss = new SubSet();
			bool needAdd = false;
			if (start[0]=='0'||end[0]=='0')
			{
				needAdd = true;
			}
			if (behavior=="+")
			{
				for (int i = int.Parse(start); i<=int.Parse(end);i+= int.Parse(increment)) 
				{
					string temp = i.ToString();
					while (needAdd&&temp.Length!=start.Length)
					{
						temp = "0" + temp;
					}
					ss.AddData(temp);
				}
			}
			if (behavior == "-")
			{
				for (int i = int.Parse(start); i >= int.Parse(end); i -= int.Parse(increment))
				{
					string temp = i.ToString();
					while (needAdd && temp.Length != start.Length)
					{
						temp = "0" + temp;
					}
					ss.AddData(temp);
				}
			}
			return ss;
		}
	}
}
